<template>
  <!--<el-col :span="4" class="leftMenu">
      <el-menu class="el-menu-vertical-demo" unique-opened router>
        <template v-for="item in menu">
            <el-submenu :index="item.url">
              <template slot="title"><i :class="item.icon"></i>{{ item.name }}</template>
              <el-menu-item  v-for="(subItem,i) in item.children" :key="i" v-if="subItem.resourceType!=1" :index="subItem.url">{{ subItem.name }}
              </el-menu-item>
            </el-submenu>
          </template>
    </el-menu>
  </el-col>-->
  <el-col :span="4" class="leftMenu">
    <el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
      <div v-for="m in menu"  @click="selectNav(m)">
        <el-menu-item :index="m.index"><i :class="m.icon" @click="selectNav"></i>{{m.name}}</el-menu-item>
      </div>
    </el-menu>
  </el-col>
</template>
<script>
  export default {
    data () {
      return {
        menu: [
          {name:'产品管理',url:'/app/product',icon: 'el-icon-message',index:'1'},
          {name:'组织信息',url:'/app/org',icon: 'el-icon-menu',index:'2'},
          {name:'企业热点',url:'/app/new',icon: 'el-icon-setting',index:'3'},
          {name:'用户管理',url:'/app/user',icon: 'el-icon-message',index:'4'},
          {name:'字典管理',url:'/app/constant',icon: 'el-icon-message',index:'5'}
        ]
      }
    },
    created(){
      this.getMenu();
    },
    methods: {
      selectNav(m) {
        var nav=[
          {navName:m.name, routeUrel:m.url}
        ]
        this.$router.push({path: m.url})
        this.$store.commit('setNav',nav)
      },
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      getMenu(){
        this.$http.get(this.baseUrl+'/resources/type/0')
          .then(function (response) {
            // 这里是处理正确的回调
            this.menu =response.data.dataList;
            console.log(this.menu)
            // this.articles = response.data["subjects"] 也可以

          }, function (response) {
            // 这里是处理错误的回调
            console.log("错误鸟");
            console.log(response)
          });
      }
    }
  }
</script>

<style>
  .leftMenu {
    position: fixed;
    overflow: hidden;
    width: 300px;
    height: 100%;
    background-color: #e4e8f1;
  }

</style>
